Skip to content

Conversation

@lsm5
Copy link
Member

@lsm5 lsm5 commented Nov 12, 2025

See individual commits.

@github-actions github-actions bot added the common Related to "common" package label Nov 12, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 12, 2025
@podmanbot
Copy link

✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6499

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 17, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 21, 2025
@lsm5 lsm5 changed the title Revert "Revert Cgroups V1 removal" Cgroups V1 removal Nov 21, 2025
@lsm5 lsm5 marked this pull request as ready for review November 21, 2025 17:58
@lsm5
Copy link
Member Author

lsm5 commented Nov 21, 2025

Seems to be doing well in containers/podman#27551 .

@containers/container-libs-maintainers PTAL.

}

// Create the cgroup.
func (c *linuxCpusetHandler) Create(ctr *CgroupControl) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, removing this is one way to deal with #417 (comment) .

… but, please, make a permanent record of the rationale. Why is removing the …CopyFromParent code fine? The commit message doesn’t say. (I don’t understand cgroups and I have no opinion. It’s quite possible that the manual copies were a bug.)

If this should be obvious to anyone minimally familiar with cgroups, I’m happy to defer to a different reviewer.

}

// Stat fills a metrics structure with usage stats for the controller.
func (c *linuxCpusetHandler) Stat(_ *CgroupControl, _ *cgroups.Stats) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the cpuset handler should stay as is now, entirely empty struct with no code, it looks like it could be removed (…and, optionally, instead a “handler” interface, we could just have a collection of stat-gathering functions)

}

// AddPid moves the specified pid to the cgroup.
func (c *CgroupControl) AddPid(pid int) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passed in #417 without comment — it’s not trivially obvious to me that removing this without replacement is fine. It might well be obvious to someone more familiar with cgroups.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per containers/podman#27551 (comment), this needs to stay.

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 24, 2025
@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

2 similar comments
@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

Packit jobs failed. @containers/packit-build please check.

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 24, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 24, 2025
@lsm5 lsm5 marked this pull request as draft November 24, 2025 19:23
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 24, 2025
lsm5 added 3 commits November 25, 2025 12:54
This reverts commit 5273685 ,
re-enabling cgv1 removal.

Signed-off-by: Lokesh Mandvekar <[email protected]>
…omParent

The manual cpusetCopyFromParent function was needed for cgroups v1 to
populate cpuset.cpus and cpuset.mems from parent cgroups. In cgroups v2,
the kernel automatically handles cpuset inheritance through the
cpuset.cpus.effective and cpuset.mems.effective interfaces.

When fs2.NewManager().Set() is called with cpuset resources, it directly
writes the values to cpuset.cpus and cpuset.mems if provided. If not
provided, the kernel ensures child cgroups have valid effective cpusets by
automatically inheriting from their parent.

Signed-off-by: Lokesh Mandvekar <[email protected]>
The Update() function previously iterated through handlers calling their
Apply() methods. With cgroups v1 removed, all handlers' Apply()
implementations were identical - they all called fs2.NewManager().Set().

This commit removes the redundant handler Apply() methods and has Update()
call fs2.NewManager().Set() directly. The Update() method now performs the
same function more efficiently without the handler indirection.

Signed-off-by: Lokesh Mandvekar <[email protected]>
lsm5 added 6 commits November 25, 2025 12:54
The github.com/opencontainers/cgroups/fs import and associated struct
fields (Blkio, CPU, CPUSet, Mem, Pid) were never used in any of the
handler implementations. These were remnants from the cgroups v1 removal.

The empty handler structs are retained as they serve as method receivers
for implementing the controllerHandler interface.

Signed-off-by: Lokesh Mandvekar <[email protected]>
The cpuset handler only had an empty Stat method that returned nil,
providing no functionality. Remove the handler entirely along with the
unused CPUset and CPUAcct controller constants which were remnants from
cgroups v1.

Signed-off-by: Lokesh Mandvekar <[email protected]>
Replace the controllerHandler interface with a simple statFunc type
and convert all handler structs to plain functions. This eliminates
unnecessary abstraction since all handlers only implemented a single
Stat method.

Changes:
- Replace controllerHandler interface with statFunc type
- Convert linuxBlkioHandler, linuxCPUHandler, linuxMemHandler, and
  linuxPidHandler structs to blkioStat, cpuStat, memoryStat, and
  pidsStat functions
- Remove init() function and factory methods (getBlkioHandler, etc.)
- Simplify handlers map to direct function references
- Update Stat() method to call functions directly
- Update AvailableControllers signature to use statFunc type

Signed-off-by: Lokesh Mandvekar <[email protected]>
This reverts commit cce5ec8.

Note: This has already gone through a revert and re-revert cycle in
commits 5273685 and
3fe402b, but that's wrong
per: containers/podman#27551 (comment) .

Signed-off-by: Lokesh Mandvekar <[email protected]>
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 25, 2025
}
return nil
path := filepath.Join(cgroupRoot, c.config.Path)
return fs2.CreateCgroupPath(path, c.config)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giuseppe could you PTAL at this diff please? You mentioned AddPid is required, but if it's only cgroup2, then I think this could be simplified as the current diff, but in that case the pid isn't even being used. I'll defer to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants